Fs = 30000;
% Modulating signal
Ts = 1/Fs;t = 0:Ts:1-Ts;
ym = sin(2*pi*10*t);
figure(1);
subplot(4,1,1);plot(t,ym);title('Modulating signal');
%Carrier signal
fc = fa*100000;Tc = 1/fc;
yc = sin(2*pi*fc*t);
subplot(4,1,2);plot(t,yc);title('Carrier signal');
 %AM Modulation
y = (1 + ym).*yc;
subplot(4,1,3);plot(t,y);title ( 'Amplitude Modulated signal');
 % AM Demodulation
 sd = y.*yc*2 - 1;
H_am = demod_filter;
sd = filter(H_am,sd);subplot(4,1,4);plot(t,sd);title('Demodulated and true message signals for AM');
function Hd = demod_filter
Fpass = 10;   % Passband Frequency
Fstop = 90;   % Stopband Frequency
Apass = 1;    % Passband Ripple (dB)
Astop = 60;   % Stopband Attenuation (dB)
Fs    = 30000;  % Sampling Frequency
 h = fdesign.lowpass('fp,fst,ap,ast', Fpass, Fstop, Apass, Astop, Fs);
 Hd = design(h, 'kaiserwin', 'MinOrder', 'any');
end


 


